#include <stdio.h>
#include <stdlib.h>
typedef struct Student
{
    int id;
    char sex;
    int age;
    char *name;
    struct Student *next;
} Student;

typedef struct LinkedList
{
    Student *list;
} LinkedList;

Student *getNode()
{
    static Student *node;
    node = malloc(sizeof(Student));
    node->next = NULL;
    return node;
}

void reverse(LinkedList *linkedList)
{
    Student *last, *now, *next;
    last = NULL;
    now = linkedList->list;
    next = NULL;
    while (now != NULL)
    {
        next = now->next;
        now->next = last;
        last = now;
        now = next;
    }
    linkedList->list = last;
}

int main()
{
    LinkedList *linkedList;
    linkedList = malloc(sizeof(LinkedList));
    linkedList->list = NULL;
    for (int i = 0; i < 10; i++)
    {
        Student *now;
        now = getNode();
        now->age = i;
        if (linkedList->list == NULL)
        {
            linkedList->list = now;
            continue;
        }
        now->next = linkedList->list;
        linkedList->list = now;
    }
    reverse(linkedList);

    while (linkedList->list != NULL)
    {
        printf("%d\n", linkedList->list->age);
        linkedList->list = linkedList->list->next;
    }
    return 0;
}